package org.example.server;

import java.io.IOException;
import java.net.ServerSocket;
import java.net.Socket;

public class HttpServer01 {

    public static void main(String[] args) throws IOException {
        final int port = 8801;
        final HttpServerCommon httpServerCommon = new HttpServerCommon("hello,nio1");
        ServerSocket serverSocket = new ServerSocket(port);
        System.out.println("Listening: http://127.0.0.1:" + port);
        while (!Thread.currentThread().isInterrupted()) {
            try {
                Socket s = serverSocket.accept();
                httpServerCommon.service(s);
            } catch (IOException ex) {
                ex.printStackTrace();
            }
        }
    }
}